﻿<!DOCTYPE html>

<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <title></title>
</head>
<body>
    <script>
        // 需求:倒计时。
        // 1. 时间戳 ：从 1970-01-01 00:00:00(计算机元年), 到某个时间点，经过的毫秒数。

        //获取某个时间点的时间戳
        let d = new Date('2022-8-17 16:00:00');
        console.log(d.getTime());
        console.log(d.valueOf());

        //获取当前时间的时间戳
        console.log(+new Date('2022-8-17 16:00:00'));
        console.log(Date.now());

        let date =Date.now();
        let date1 = new Date(date);
        y = date1.getFullYear() + `-`;
        m = (date1.getMonth() + 1 < 10 ? '0' + (date1.getMonth() + 1) : date1.getMonth() + 1) + '-';
        d = date1.getDate(); +` `;
        h = date1.getHours() + ':';
        m = date1.getMinutes() + ':';
        s = date1.getSeconds();
        console.log(h + m + s);
    </script>
</body>
</html>